/*** author: sailing date: 2018/10/23 ***/

<template>
	<div class="timeContent">
		<mu-button @click="startTime();" color="secondary">{{
			bntName
		}}</mu-button>
		<mu-list textline="three-line">
			<mu-divider></mu-divider><br />
			<mu-list-item avatar :ripple="false" button>
				<mu-list-item-content>
					<mu-list-item-title>开始时间</mu-list-item-title>
					<mu-list-item-sub-title>
						<mu-text-field
							v-model="rtime.start"
							type="string"
							placeholder=""
							icon=""
						></mu-text-field
						><br />
					</mu-list-item-sub-title>
				</mu-list-item-content>
			</mu-list-item>
			<mu-divider></mu-divider><br />
			<mu-list-item avatar :ripple="false" button>
				<mu-list-item-content>
					<mu-list-item-title>结束时间</mu-list-item-title>
					<mu-list-item-sub-title>
						<mu-text-field
							v-model="rtime.end"
							type="string"
							placeholder=""
							icon=""
						></mu-text-field
						><br />
					</mu-list-item-sub-title>
				</mu-list-item-content>
			</mu-list-item>
		</mu-list>
	</div>
</template>

<script type="text/javascript">
import tools from '../server/tools.js'
export default {
	data() {
		return {
			bntName: '开始'
		};
	},
	props: ["rtime"],
	methods: {
		startTime() {
			let time = tools.getTime();
			const self = this;

			if (self.bntName == "开始") {
				this.rtime.start = time;
				self.bntName = "结束";
			} else {
				self.bntName = "开始";
			}

			function start() {
				setTimeout(function() {
					let time = tools.getTime();
					self.rtime.end = time;
					if (self.bntName == "结束") start();
				}, 500);
			}

			start();
		}
	},
	watch: {
		$route: function() {
			//console.log("----...---:", this.navSelect, this.$route.path)
		}
	}
};
</script>

<style lang="less">
.timeContent {
}
</style>
